<?php
    session_start();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>锤子科技商城注册</title>

<style>
body{ background-color:#CFF;}
#tbody{ 
    width:1100px; 
	height: auto; 
	margin:0 auto; 
	padding-top: 10px;
}
#xiugaicode{
	background-color: #FFF;
	width: 600px;
	margin: 100px auto;
	padding-top: 20px;
	padding-bottom: 30px;
	padding-left: 50px;
	}
#xiugaititle{
	margin: 0;
	padding: 0;
	}
#xiugaititle img{
	width: 50px;
	height: 50px;
	vertical-align: middle;
	}
#xiugaititle span{
    display: block;
	}
#xiugaidiv2{
	width: 500px;
	margin: 0 auto;	
	overflow: hidden
	}
#formxiugai dt{
	float: left;
	margin:10px;
	width: 110px;
	vertical-align: middle;
	display: inline-block;
	height: 25px;
	 text-align:justify;
     text-align-last:justify;
}
#formxiugai dt:after{
     display:inline-block;
     overflow:hidden;
     width:100%;
     height:0;
     content:'';
     vertical-align: middle;
}
#formxiugai dd{
	float: left;
	margin:10px;
	width: 340px;
	height: 25px;
	}
#formxiugai p{
	margin: 0;
	padding: 0;
	}
#formxiugai input{
     width: 180px;
	}


.error{
	color:red;
}






</style>



<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="../js/validate-1.14.0.min.js"></script>

<script>

$().ready(function() {

$(function(){
  $('#formxiugai').validate({
		rules:{
			pw01gai:{
				required:true,
				rangelength:[6,12]
			},
			pw02gai:{
				required:true,
				equalTo:'#pw01gai'
			}	
		
		},
		messages:{
			pw01gai:{
				required:'请设置一个密码',
				rangelength:'密码位数为6到12位'
			},
			pw02gai:{
				required:'请再次确认密码',
				equalTo:'两次输入密码不相符'
			}
						
		}
	});	
  });
});











</script>



</head>

<body>
<?php
include "../mysql/mysql.php";
$aa = new mysql;
$aa->link("");
include "../myfunction.php";
$bb= new myfunction;
if(@$_SESSION['userid'] != '' && @$_POST['pw01gai']!= ''){
 
 $uname = @$_SESSION['userid'];


$password =$bb->jiami(@$_POST['pw01gai']);


$sql = "UPDATE user_info SET user_pw= '".$password."' WHERE user_name='".$uname."' ";
$result= $aa->excu($sql);

if($result == 'TURE'){
	 $gai = 1;
	echo $gai;
	}

}
?>
<div id="tbody">

    <div id="xiugaicode">
         <div style=" margin: 0 auto; width: 200px;"><p id="xiugaititle"><span><img src="../img/head-logo.jpg" />　<strong>修改密码</strong></span></p></div>
        <div id="xiugaidiv2">
          <form method="post" action="" id="formxiugai" enctype="multipart/form-data"> 
            <dl>
                
                <dt>密码</dt><dd><p><input id="pw01gai" name="pw01gai" type="password" placeholder="请输入密码"><span class="error">*</span></p></dd>
                <dt>重复密码</dt><dd><p><input id="pw02gai" name="pw02gai" type="password" placeholder="请再次输入密码"><span class="error">*</span></p></dd>
                                        
            </dl>
             <div style=" margin: 0 auto; width: 200px;"><input type="submit" name="submit" value="修改密码" id="xiugai" style='font-size:20px'></div>
           </form>
           <div>
		   <?php if(@$gai == 1){  ?>
		       <p style=" text-align: center; color: red;">密码修改成功！5s后跳转到商城主页</p>
		   <?php
		   echo "<meta http-equiv=\"refresh\" content=\"5;url='../shoppingmall.php'\">";
		   }
		   ?></div>
        </div>
    
    </div>









</div>
<?php
include "../mysql/mysqlclose.php";
?>

</body>
</html>